#define _CRT_SECURE_NO_WARNINGS 1



struct Com
{
    bool operator()(const pair<int, string>& left, const pair<int, string>& right)const
    {
        return left.first > right.first;
    }
};
class Solution {
public:
    vector<string> sortPeople(vector<string>& names, vector<int>& heights) {
        multimap<int, string, Com> hash;
        for (int i = 0; i < names.size(); i++)
        {
            hash.insert(pair<int, string>(heights[i], names[i]));
        }

        vector<string> ans(names.size());
        int i = 0;
        for (auto& kv : hash)
        {
            ans[i++] = kv.second;
        }
        return ans;
    }
};


class Solution {
public:
    vector<string> sortPeople(vector<string>& names, vector<int>& heights) {
        vector<int> index(heights.size());
        for (int i = 0; i < index.size(); i++)
        {
            index[i] = i;
        }

        sort(index.begin(), index.end(), [&](int i, int j) {
            return heights[i] > heights[j];
            });

        vector<string> ans;
        for (auto idx : index)
        {
            ans.push_back(names[idx]);
        }
        return ans;
    }
};